<template>
	<view class="content">
		<view>{{num}}</view>
		<button @click="num++">+1</button>
		<view v-for="item in list" :key="item.id">
			<text>{{item.id}}</text>
			 ---- 
			<text>{{item.todo}}</text>
		</view>
		<button @tap="toIndex">跳到个人中心页面</button>
		<view>{{app.count}}</view>
		<button @click="add">+1</button>
	</view>
</template>

<script setup>
	import {ref,reactive,onMounted} from "vue"
	import {useStore} from "vuex"
	const store = useStore();
	const {app} = store.state;
	
	const num = ref(0);
	const list = reactive([
		{id:1,todo:"学习uniapp1",done:false},
		{id:2,todo:"学习uniapp2",done:true},
		{id:3,todo:"学习uniapp3",done:false},
	])
	onMounted(()=>console.log("vue3的生命周期~"))
	
	const toIndex = ()=>{
		// vue: this.$router.push()  .replace()   .
		// 小程序：wx.navigateTo()     wx.xxx
		// uniapp：uni.navigateTo()    uni.xxx
		uni.navigateTo({
			url:"/pages/user/user?id=123"
		})
	}
	
	const add = ()=>{
		store.commit("app/addCount",2)
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
